<extend name="public@base5"/>
<block name="head">
	<link rel="stylesheet" href="__STATIC__/css/mall.css?v={$_static_version}"></link>
        <include file="theme/functions"/>       
</block>
<block name="main">
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="item_images[]" value="{filepath}">
        <input class="form-control" id="photo-{id}-name" type="text" name="image_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:34px;width: 44px;"
             onclick="imagePreviewDialog(this.src);">
        <a class="btn btn-default" href="javascript:uploadOneImage('图片上传','#photo-{id}');"><i class="fa fa-upload fa-fw"></i></a>
        <a class="btn btn-danger" href="javascript:(function(){$('#saved-image{id}').remove();})();"><i class="fa fa-trash fa-fw"></i></a>
        <a class="btn btn-success" href="javascript:(function(){$('#saved-image{id}').before($('#saved-image{id}').next());})();"><i class="fa fa-arrow-down fa-fw"></i></a>
    </li>
</script>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li class="nav-item">
				<a class="nav-link" href="{:url('Store/subIndex',['type'=>$type])}">商品列表</a>
			</li>
			<li class="nav-item">
				<a class="nav-link active" href="{:url('Store/add',['type'=>$type])}">添加商品</a>
			</li>
		</ul>
		<form method="post" class="js-ajax-form margin-top-20" action="admin/stores">
			<input type="hidden" name="store_type" value="{$type}">
                        
			<div class="row mb-3">
				<label for="input-item_name" class="col-sm-2 col-form-label text-sm-end"><span class="form-required">*</span>商品名称</label>
				<div class="col-md-8 col-sm-10">
					<input type="text" class="form-control" id="input-item_name" name="item_name">
				</div>
			</div>
                        <div class="row mb-3">
				<label for="input-item_type" class="col-sm-2 col-form-label text-sm-end"><span class="form-required">*</span>商品类型</label>
				<div class="col-md-2 col-sm-2">
					<input type="text" class="form-control" id="input-item_type" name="item_type" placeholder="商品类型" >
				</div>
				<div class="col-md-8 col-sm-8">
					<foreach name="item_types" item="vo">
						<a class="btn btn-primary js-select-type" href="#">{$vo.item_type}</a>
					</foreach>
				</div>
			</div>
                        <if condition="$booth_type==1">
                        <div class="row mb-3">
				<label for="input-item_name" class="col-sm-2 col-form-label text-sm-end"><span class="form-required">*</span>价格</label>
				<div class="col-md-2 col-sm-10">
					<input type="number" class="form-control" id="input-item_name" name="item_price">
				</div>

				<label for="input-item_order" class="col-sm-2 col-form-label text-sm-end"><span class="form-required">*</span>排序</label>
				<div class="col-md-2 col-sm-10">
					<input type="number" class="form-control" id="input-item_order" name="item_order" value="{$item_order|default=1000}">
				</div>
			</div>
                        </if>
			<div class="row mb-3">
				<label for="input-item_desc" class="col-sm-2 col-form-label text-sm-end"><span class="form-required">*</span>商品描述</label>
				<div class="col-md-8 col-sm-10">
					<input type="text" class="form-control" id="input-item_desc" name="item_desc" placeholder="商品描述">
				</div>
			</div>

			
                        <div class="row mb-3">
				<label for="input-item_type" class="col-sm-2 col-form-label text-sm-end">标签</label>
				<div class="col-md-8 col-sm-8">
					<div id="tag_selected_container">
						
					</div>
					<div id="tag_container"></div>
					<a class="btn btn-primary add-tag" data-type="{$booth_type}"><i class="fa fa-plus"></i></a>
				</div>
			</div>
			<div class="row mb-3">
				<label for="thumbnail-preview" class="col-sm-2 col-form-label text-sm-end pt-0"><span class="form-required">*</span>图标</label>
				<div class="col-md-8 col-sm-10">
                                    <input type="hidden" name="item_icon" id="thumbnail" value="">
                                    <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                                        <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                             id="thumbnail-preview"
                                             width="135" style="cursor: pointer"/>
                                    </a>
                                    <br>
                                    <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
                                </div>
                        </div>
                        <div class="row mb-3">
                            <label for="item_icon" class="col-sm-2 col-form-label text-sm-end">相册</label>
                            <div class="col-md-8 col-sm-10 image_list">
                                {:_parse_vars($item_images, 'item_images')}
                            </div>
                        </div>
			<div class="row mb-3">
				<div class="offset-md-2 col-sm-10">
					<button type="submit" class="btn btn-primary js-ajax-submit">
						<i class="fa fa-save fa-fw"></i> {:lang('ADD')}
					</button>
                                    <a class="btn btn-danger js-dialog-btn" data-msg="确定不保存吗?" href="{:url('Store/subIndex',['type'=>$type])}">
                                        <i class="fa fa-save fa-fw"></i> 取消
                                    </a>
				</div>
			</div>
		</form>

	</div>
</block>

<block name="scripts">
	<script src="__STATIC__/js/mall.js"></script>
        <include file="theme/scripts"/>
</block>